package com.itheima.api.mathdemo;

import java.util.Random;

public class MathDemo {
    public static void main(String[] args) {
        //返回参数的绝对值
        int abs = Math.abs(10);
        System.out.println(abs);

        //向上取整
        double ceil = Math.ceil(10.2);
        System.out.println(ceil);

        //向下取整
        double floor = Math.floor(10.5);
        System.out.println(floor);

        //四舍五入
        long round = Math.round(10.5);
        System.out.println(round);

        //返回两个int值中的最大值
        int max = Math.max(10, 20);
        System.out.println(max);

        // 返回两个int值中的最小值
        int min = Math.min(10, 20);
        System.out.println(min);

        //返回a的b次幂
        double pow = Math.pow(2, 3);
        System.out.println(pow);

        //返回10次值为double的[0,1)正值
        for (int i = 0; i < 10; i++) {
            double random = Math.random();
            System.out.println(random);
        }
        int v = (int)(Math.random() * 10 +1);
        System.out.println("v = " + v);

        Random random = new Random();
        for (int i = 0; i < 10 ; i++) {
            System.out.println("random = " + random);
        }
    }
}
